/**
Group: efl/radio (@since 1.23)
	 Part Text: efl.text (required)
	 Part Swallow: efl.content (required)
	 Signal: efl,content,set
	 Signal: efl,content,unset
	 Signal: efl,state,disabled
	 Signal: efl,state,enabled
	 Signal: efl,state,selected
	 Signal: efl,state,unselected
	 Signal: efl,text,set
	 Signal: efl,text,unset
*/
group { name: "efl/radio";
   data.item: "version" "123";
#define ICON     1
#define LABEL    2
#define MASK     3
#define DISABLE  4
#define SELECTED 8
   script {
      BUTTONMODE_SCRIPT2
      public sel;
      public eval_sel(m) {
         if (m) {
            set_state(PART:"ck_check", "selected", 0.0);
         } else {
            set_state(PART:"ck_check", "default", 0.0);
         }
      }
   }
   parts {
      part { name: "shadow"; type: SPACER;
         description { state: "default";
         }
         desc { "pressed"; inherit;
         }
         desc { "disabled"; inherit;
         }
      }
      swallow { "efl.background"; nomouse;
         desc { "default";
            visible: 0;
         }
         desc { "visible"; inherit;
            visible: 1;
         }
      }
      rect { "icon_clip";
         desc { "default";
            color: 255 255 255 255; // no cc
         }
         desc { "pressed"; inherit;
            color: 255 255 255 255; // no cc
         }
         desc { "disabled"; inherit;
            color: 255 255 255 64; // no cc
         }
      }
      swallow { "efl.content"; nomouse;
         required;
         clip_to: "icon_clip";
         scale: 1;
         desc { "default";
            fixed: 1 0;
            align: 0.0 0.5;
            rel1.to_x: "base";
            rel2.to_x: "base";
            rel1.offset: 4 4;
            rel1.relative: 1.0 0.0;
            rel2.relative: 0.0 1.0;
            rel2.offset: 4 -5;
            visible: 0;
            offscale;
         }
         desc { "visible"; inherit;
            fixed: 1 0;
            aspect: 1.0 1.0;
            visible: 1;
            min: ICMIN ICMIN;
         }
         desc { "icononly"; inherit;
            fixed: 0 0;
            align: 0.5 0.5;
            rel2.relative: 1.0 1.0;
            rel2.offset: -5 -5;
            rel2.to_x: "";
            visible: 1;
            min: ICMIN ICMIN;
         }
      }
      part { name: "base"; type: RECT;
         scale: 1;
         description { state: "default";
            align: 0.0 0.5;
            min: 13 13;
            max: 13 13;
            rel1.offset: 4 4;
            rel2.relative: 0.0 1.0;
            rel2.offset: 4 -5;
            aspect: 1.0 1.0; aspect_preference: VERTICAL;
            offscale;
            visible: 0;
            offscale;
         }
         desc { "pressed"; inherit;
         }
         desc { "disabled"; inherit;
         }
      }
      part { name: "ck_bg";
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            rel.to: "base";
            image.normal: "i-radio";
            min: 15 15;
            max: 15 15;
            color_class: "/bg/normal/radio/base";
         }
         desc { "disabled"; inherit;
            color_class: "/bg/disabled/radio/base";
         }
      }
      part { name: "ck_check";
         scale: 1;
         description { state: "default" 0.0;
            color_class: "/fg/selected/radio/radio";
            fixed: 1 1;
            rel.to: "base";
            image.normal: "i-radio";
            min: 15 15;
            max: 15 15;
            visible: 0;
         }
         description { state: "selected" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         desc { "disabled"; inherit;
            visible: 0;
         }
      }
      part { name: "ck_press";
         scale: 1;
         description { state: "default" 0.0;
            color_class: "/fg/pressed/radio/radio";
            fixed: 1 1;
            rel.to: "base";
            image.normal: "i-radio";
            min: 15 15;
            max: 15 15;
            visible: 0;
         }
         description { state: "pressed" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
      }
      text { "efl.text"; nomouse;
         required;
         scale: 1;
         desc { "default";
            fixed: 0 1;
            color_class: "/fg/normal/radio/text";
            rel1.offset: 0 4;
            rel1.relative: 1.0 0.0;
            rel1.to_x: "efl.content";
            rel2.offset: -5 -5;
            text { font: FN; size: 10;
               align: 0.0 0.5;
               min: 0 0;
            }
            visible: 0;
            offscale;
            min: 0 ICMIN;
         }
         desc { "visible"; inherit;
            fixed: 0 0;
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "pressed_visible"; inherit;
            fixed: 0 0;
            color_class: "/fg/pressed/radio/text";
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "textonly"; inherit;
            fixed: 0 0;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "pressed_textonly"; inherit;
            fixed: 0 0;
            color_class: "/fg/pressed/radio/text";
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "disabled_visible"; inherit;
            fixed: 0 0;
            color_class: "/fg/disabled/radio/text";
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "disabled_textonly"; inherit;
            fixed: 0 0;
            color_class: "/fg/disabled/radio/text";
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
      }
      rect { "event";
         ignore_flags: ON_HOLD;
         desc { "default";
            color: 0 0 0 0; // no cc
         }
         desc { "disabled"; inherit;
            visible: 0;
         }
      }
   }
   programs {
      EFL_UI_CLICKABLE_PART_BIND(event)
      program { signal: "efl,state,selected"; source: "efl";
         script {
            new m = get_int(sel) | SELECTED;
            set_int(sel, m);
            eval_sel(m);
         }
      }
      program { signal: "efl,state,unselected"; source: "efl";
         script {
            new m = get_int(sel) & ~SELECTED;
            set_int(sel, m);
            eval_sel(m);
         }
      }
      program { signal: "efl,text,set"; source: "efl";
         script { flag_set(LABEL); }
      }
      program { signal: "efl,text,unset"; source: "efl";
         script { flag_unset(LABEL); }
      }
      program { signal: "efl,content,set"; source: "efl";
         script { flag_set(ICON); }
      }
      program { signal: "efl,content,unset"; source: "efl";
         script { flag_unset(ICON); }
      }
      program { signal: "efl,state,disabled"; source: "efl";
         script { flag_set(DISABLE); }
      }
      program { signal: "efl,state,enabled"; source: "efl";
         script { flag_unset(DISABLE); }
      }
      program { signal: "efl,state,disabled"; source: "efl";
         action:  STATE_SET "disabled" 0.0;
         target: "ck_check";
         target: "ck_bg";
      }
      program { signal: "efl,state,enabled"; source: "efl";
         action:  STATE_SET "default" 0.0;
         target: "ck_check";
         target: "ck_bg";
      }
      program { signal: "mouse,down,1"; source: "event";
         action: STATE_SET "pressed" 0.0;
         target: "ck_press";
      }
      program { signal: "mouse,up,1"; source: "event";
         action: STATE_SET "default" 0.0;
         target: "ck_press";
      }
   }
}
